// --------------------------------------------------------------------
//   name 	: Server Settings API
//   desc 	: Retrieves settings of the server the user is playing on.
//   version	: Beta v0.1
//   dev 	: JelianSD
// --------------------------------------------------------------------
// DEPENDENCIES
// 	None
// --------------------------------------------------------------------
// CHANGE HISTORY
// 0.1	Initial Release
// --------------------------------------------------------------------

plugins.ServerSettings = {

	'UnitSpeeds' : function() {
		var UnitSpeedsArray = getValue("WorldUnitSpeeds");
		if(UnitSpeedsArray) {
			return UnitSpeedsArray;
		} else {
			return new Array(18,22,18,18,9,10,10,11,30,30,10,35);
		}
	},
	'isPaladin' : function() {
		var WorldPaladin = getValue("WorldPaladin");
		if(WorldPaladin=="true" || WorldPaladin=="false") {
			return WorldPaladin;
		} else {
			return true;
		}
	},
	'enhance_game_overview_villages' : function() {
		pUrl = twe.Server+'/help2.php?article=units';
		pData = '';
		Type = 'html';
		jQuery.get( pUrl, pData, function(xhr) {
		
			var UnitSpeedsArray = new Array();
			var isPaladin = "true";
			for(var i=0;i<UnitList.length;i++) {
				var TempValue = $("tr:has(> td > a > img[src*='"+UnitList[i]+"']) td", xhr);
				if(TempValue[TempValue.length-2]) {
					UnitSpeedsArray[i] = TempValue[TempValue.length-2].innerHTML;
					if(parseInt(UnitSpeedsArray[i])<1) UnitSpeedsArray[i]="1"; // Just incase the field returns a NaN save the variable as 1 so the plugins code wont break
				} else {
					UnitSpeedsArray[i] = "1337";
					isPaladin = "false";
				}
			}
			setValue("WorldUnitSpeeds",UnitSpeedsArray);
			setValue("WorldPaladin",isPaladin);
		
		});
	},
	'info' : {
		'mandatory' : true,
		'name' : "Server Settings API",
		'desc' : "Retrieves settings of the server the user is playing on.",
		'version' : "0.1",
		'dev' : "JelianSD"
	}

};

